
/**
 * Please modify this class to meet your needs
 * This class is not complete
 */

package com.cctv.esb._interface.smssendsubscribeservice._1_0;

import java.util.logging.Logger;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.XmlSeeAlso;

import org.apache.commons.lang.StringUtils;
import org.apache.cxf.interceptor.InInterceptors;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.support.DefaultSingletonBeanRegistry;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ConfigurableApplicationContext;

import com.cctv.esb.schema.pubsub._1.ResponseType;
import com.cctv.ims.schema.smssendservice._1.SMSSendServiceRequestType.ReceivePersons;
import com.ctvit.framework.web.context.ContextHolder;
//import com.ctvit.sms.platform.domain.MsgReq;
//import com.ctvit.sms.platform.service.SmsService;

/**
 * This class was generated by Apache CXF 2.5.0
 * 2013-04-02T17:24:54.127+08:00
 * Generated source version: 2.5.0
 * 
 */

@javax.jws.WebService(
                      serviceName = "SMSSendService",
                      portName = "SMSSendServiceHttpPort",
                      targetNamespace = "http://cctv.com/IMS/service/SMSSendServiceType/1.0",
                      endpointInterface = "com.cctv.esb._interface.smssendsubscribeservice._1_0.SMSSendSub")
//@InInterceptors(interceptors="org.apache.cxf.interceptor.LoggingInInterceptor")                      
public class SMSSendSubImpl implements SMSSendSub,ApplicationContextAware  {

    private static final Logger LOG = Logger.getLogger(SMSSendSubImpl.class.getName());
    
    private ConfigurableApplicationContext applicationContext;
    
    public void setApplicationContext(ApplicationContext applicationContext)
    throws BeansException {
    	this.applicationContext =  (ConfigurableApplicationContext)applicationContext; 
		
	}
    /* (non-Javadoc)
     * @see com.cctv.esb._interface.smssendsubscribeservice._1_0.SMSSendSub#getServiceInfo(com.cctv.esb.schema.monitor._0.GetServiceInfoRequestType  getServiceInfoRequest )*
     */
    public com.cctv.esb.schema.monitor._0.GetServiceInfoResponseType getServiceInfo(com.cctv.esb.schema.monitor._0.GetServiceInfoRequestType getServiceInfoRequest) { 
        LOG.info("Executing operation getServiceInfo");
        try {
            com.cctv.esb.schema.monitor._0.GetServiceInfoResponseType _return = null;
            return _return;
        } catch (java.lang.Exception ex) {
            ex.printStackTrace();
            throw new RuntimeException(ex);
        }
    }

    /* (non-Javadoc)
     * @see com.cctv.esb._interface.smssendsubscribeservice._1_0.SMSSendSub#subscribe(com.cctv.esb.schema.messagehead._0.RequestHeadType  requestHead ,)com.cctv.ims.schema.smssendservice._1.SMSSendServiceRequestType  smsSendServiceRequest )*
     */
    public com.cctv.esb.schema.pubsub._1.ResponseType subscribe(com.cctv.esb.schema.messagehead._0.RequestHeadType requestHead,com.cctv.ims.schema.smssendservice._1.SMSSendServiceRequestType smsSendServiceRequest) { 
	   String xmlRequesteXML = (String)applicationContext.getBean("xmlRequest");
	   DefaultSingletonBeanRegistry registry = (DefaultSingletonBeanRegistry)applicationContext.getBeanFactory();
	   registry.destroySingleton(xmlRequesteXML);
//       System.out.println("aa="+xmlRequesteXML+";bb="+smsSendServiceRequest.getDataFormCode());
    	ResponseType r=null;
//    	MsgReq msgReq=new MsgReq();
//         msgReq.setZCrtUsr(smsSendServiceRequest.getSubmitUsrCode());
//         msgReq.setZMsgContent(smsSendServiceRequest.getMsgContent());
//         msgReq.setZFormId(smsSendServiceRequest.getDataFormCode());
//         if (smsSendServiceRequest.getReceivePersons()!=null){
//         	String rcs="";ReceivePersons rcPers=null;String usr="";Boolean fBoolean=false;
//         	rcPers=smsSendServiceRequest.getReceivePersons();
//         	for (int i = 0; i < rcPers.getReceiveUsrCode().size(); i++) {
//         		usr=rcPers.getReceiveUsrCode().get(i);
//         		if (("00002993").equals(usr)){
//         			fBoolean=true;
//         		}
// 				rcs+=usr+",";
// 			}
//         	if (fBoolean){
//         		rcs+="00104082,";
//         	}
//         	if (!StringUtils.isEmpty(rcs)){
//         		rcs=rcs.substring(0,rcs.length()-1);
//         	}
//         	 msgReq.setZMsgReceiver(rcs);
//         }
//         msgReq.setZMsgType(smsSendServiceRequest.getTriggerType());
//         msgReq.setZRegId(smsSendServiceRequest.getSMSRegisterNo());
//         msgReq.setZSrcSysId(smsSendServiceRequest.getSourceSysID());
//         msgReq.setZWfId(smsSendServiceRequest.getWorkFlowCode());
//         msgReq.setZRelatedSysId(smsSendServiceRequest.getRemindSysID()==null?"":smsSendServiceRequest.getRemindSysID());
//         SmsService smsService=(SmsService)ContextHolder.getBean(SmsService.class);
//         if (("EM11007").equals(msgReq.getZRegId())&&("99").equals(msgReq.getZWfId())){//�����޸�����
//        	 msgReq.setZMsgContent(msgReq.getZMsgContent()+"(ע��:��Ŵ��Ŀ�ѱ��ļ���������Ҫ������ַϵͳ���������������������֪ͨ�������ý�Ŀ��Ƶ��������Ա���Ŀ)");
//         }
//         if (("EM11005").equals(msgReq.getZRegId())&&StringUtils.length(msgReq.getZFormId())==12){//��ַ�����޸�����֪ͨ������Ա
//        	 msgReq.setZMsgContent(msgReq.getZMsgContent()+"(ע��:��Ŵ��Ŀ�ѱ��ļ���������Ҫ��ϵ�ർЭ�̸��Ŀ�����ⲥ���¹�)");
//         }
//         try {
//         	MsgReq rMsgReq=smsService.saveMsgRequest(msgReq);
//         	if (("0").equals(rMsgReq.getZMsgStatus())){
//         		return ResponseType.FAIL;
//         	}else{
         		return ResponseType.OK;
//         	}
// 		} catch (Exception e) {
// 			e.printStackTrace();
// 			return ResponseType.OK;
// 		}
    }

}
